import 'package:flutter/material.dart';

class PrimaryScrollControllerPage extends StatefulWidget {
  @override
  _PrimaryScrollControllerPageState createState() =>
      _PrimaryScrollControllerPageState();
}

class _PrimaryScrollControllerPageState
    extends State<PrimaryScrollControllerPage> {
  ScrollController scrollController = ScrollController(initialScrollOffset: -500);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        actions: <Widget>[
          MaterialButton(
            child: Text('上移'),
            onPressed: () {
              scrollController.jumpTo(10);
            },
          ),
          MaterialButton(
            child: Text('下移'),
            onPressed: () {
              scrollController.jumpTo(0);
            },
          )
        ],
      ),
      body: PrimaryScrollController(
        child: Container(
          height: 1000,
          color: Colors.green,
          child: Text('PrimaryScrollControllerPrimaryScrollControllerPrimaryScrollController'),
        ),
        controller: scrollController,
      ),
    );
  }
}
